﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BLL;

namespace DAL.Linq
{
    public class LinqSYS_USER_Dao : ISYS_USER_Dao
    {
        #region IDao<SYS_USERInfo,int> Members

        /// <summary>
        /// Gets a list of all SYS_USERs.
        /// </summary>
        /// <returns>List of SYS_USERs.</returns>
        public IList<SYS_USER> GetAll()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Gets a specific SYS_USER.
        /// </summary>
        /// <param name="userID">Unique UserID identifier.</param>
        /// <returns>SYS_USER.</returns>
        public SYS_USER GetById(int userID)
        {
            throw new NotImplementedException();
        }


        public SYS_USER GetLogin(string action, string usercode, string userpass)
        {
            SYS_USER userInfo = null;
            using (InvoiceDataContext db = DataContextFactory.CreateContext())
            {
                try
                {
                    userInfo = Mapper.ToBusinessObject(db.sp_Users(action,usercode,userpass).FirstOrDefault());
                }
                catch { }
                finally
                {
                    if (db != null)
                        db.Dispose();
                }
            }
            return userInfo;
        }
        #endregion
    }
}
